Skip to content

fix: Make TestData value_for_all return its value when targeting is off - #567

Merged
keelerm84 merged 1 commit into
mainfrom
mk/SDK-3477/value-for-all
Nov 6, 2026
Merged

keelerm84 merged 1 commit into
mainfrom
mk/SDK-3477/value-for-all

Conversation

@keelerm84

@keelerm84 keelerm84 commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Summary

FlagBuilder.value_for_all (in TestData) and FlagBuilderV2.value_for_all (in TestDataV2) replaced the flag's variations with the single value and called variation_for_all(0), which leaves the off variation unchanged. A new test flag is a boolean flag with off variation 1, so the built flag had variations: [value] and offVariation: 1. That index is out of range, so the flag failed to evaluate (malformed flag) when targeting was off. The method is documented to return the value whether targeting is on or off.

value_for_all now also sets the off variation to 0 in both builders. variation_for_all is unchanged; it still leaves the off variation alone.

The new tests check the built flag with targeting on and off for both builders, and check that the client evaluates a value_for_all flag with targeting off to the value with an OFF reason.

This matches the Ruby fix in launchdarkly/ruby-server-sdk#489.

Opened from termag


Note

Overview
Fixes TestData / TestDataV2 so value_for_all behaves as documented when targeting is off.

Previously, value_for_all replaced variations with a single value and set fallthrough via variation_for_all(0), but left off variation at the default boolean flag index (1). With only one variation, that index was invalid and evaluation failed when targeting was off. The builders now also call off_variation(0) so the off path returns the same value.

Tests cover the built flag shape (including targeting off) for both builders, plus a client evaluation test asserting value 'x' with reason OFF when targeting is disabled.

Reviewed by Cursor Bugbot for commit d9958e4. Bugbot is set up for automated code reviews on this repo. Configure here.

@keelerm84
keelerm84 marked this pull request as ready for review November 5, 2026 19:14
@keelerm84
keelerm84 requested a review from a team as a code owner November 5, 2026 19:14
@keelerm84
keelerm84 merged commit 70565bb into main Nov 6, 2026
18 checks passed
@keelerm84
keelerm84 deleted the mk/SDK-3477/value-for-all branch November 6, 2026 17:06
kinyoklion pushed a commit that referenced this pull request Nov 12, 2026
🤖 I have created a release *beep* *boop*
---


##
[9.21.0](9.20.0...9.21.0)
(2026-11-12)


### Features

* Add experimental support for flag overrides, read from local JSON or
YAML files or supplied by a custom override source
([6e05c04](6e05c04))
* Mark evaluations that a flag override affected with `overrideAffected`
in the evaluation reason, and count them under separate summary counters
([6e05c04](6e05c04))


### Bug Fixes

* Keep FDv2 polling running after a network error
([#569](#569))
([ad37b18](ad37b18))
* Make TestData value_for_all return its value when targeting is off
([#567](#567))
([70565bb](70565bb))
* Stop the components that already started when the client fails to
start
([6e05c04](6e05c04))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Overview**
> Bumps the SDK from **9.20.0** to **9.21.0** across release metadata
(`pyproject.toml`, `ldclient/version.py`,
`.release-please-manifest.json`, `PROVENANCE.md`) and adds the
**9.21.0** section to `CHANGELOG.md`.
> 
> That changelog documents what ships in this release: **experimental
flag overrides** (local JSON/YAML or a custom source), evaluations
annotated with `overrideAffected` in the reason plus separate summary
counters, and fixes for **FDv2 polling** after network errors,
**`TestData.value_for_all`** when targeting is off, and **stopping
already-started components** when client startup fails.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
19fd550. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants